﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApp
{
    public class test1
    {
        public string Names { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            new TestClass2();

            //new Program().invoke();

            //int[] a = new int[10] { 3, 4, 2, 6, 8, 22, 1, 5, 7, 9 };

            //new TestClass().SelectOrder(a);

            Console.Read();
        }

        static Node GetSingleNode(int length)
        {
            Node root = null;
            for (int i = 0; i < length; i++)
            {
                root = new Node { next = root, value = i };
            }
            return root;
        }

        public void invoke()
        {
            string sentence = "the quick brown fox jumps over the lazy dog";
            string[] words = sentence.Split(' ');

            //标准查询
            var query = from word in words
                        group word.ToUpper() by word.Length into gr
                        orderby gr.Key
                        select new { Length = gr.Key, Words = gr };

            //Lambda
            var query2 = words.GroupBy(w => w.Length, w => w.ToUpper())
                .Select(g => new { Length = g.Key, Words = g })
                .OrderBy(o => o.Length);

            var query3 = words.GroupBy(w => w.Length, w => w.ToUpper())
                .Select(g => new { Length = g.Key, Words = g })
                .OrderBy(o => o.Length);

            foreach (var obj in query2)
            {
                Console.WriteLine("Words of Length {0}:", obj.Length);
                foreach (string word in obj.Words)
                    Console.WriteLine(word);
            }
        }
    }



    public class Node
    {
        public Node next;
        public int value;
    }
}
